package com.smcad.gsm;

import android.content.Context;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ZoomControls;

import com.google.android.maps.MapActivity;
import com.smcad.gsm.view.LocationViewers;

public class Main extends MapActivity {
	
	private static Main instance;

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		instance = this;
		setContentView(R.layout.map);
		initMap();
		initButtons();
	}
	
	private void initButtons() {
		// create a local listener
		OnClickListener todayListener = new OnClickListener() {
			public void onClick(View v) {
				Utilities.showToast("Today...", Main.getContext());
			}
		};

		// create a local listener
		OnClickListener weekListener = new OnClickListener() {
			public void onClick(View v) {
				Utilities.showToast("Week...", Main.getContext());
			}
		};
		
		// Listen for button clicks.
		Button button = (Button) findViewById(R.id.doAccess);
		button.setOnClickListener(todayListener);
		
		button = (Button) findViewById(R.id.doOverlay);
		button.setOnClickListener(weekListener);

	}

	public static Context getContext() {
        return instance;
    }
	
	private void initMap() {
		ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
		zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				LocationViewers.mapView.getController().zoomIn();
			}
		});
		zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				LocationViewers.mapView.getController().zoomOut();
			}
		});
	}

	/**
	 * Must let Google know that a route will not be displayed
	 */
	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
}